package com.nanyang.tms.service.weight.impl.flow;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.nanyang.common.core.flow.context.TransHandlerContext;
import com.nanyang.common.core.flow.convert.TransConvert;
import com.nanyang.common.core.flow.factory.AbstranctTransPipelineFactory;
import com.nanyang.common.core.flow.invoker.DefaultTransPipeline;
import com.nanyang.common.core.flow.invoker.TransPipeline;
import com.nanyang.tms.api.dto.request.waybill.CalWeightRequest;
import com.nanyang.tms.domain.weight.context.WeightContext;
import com.nanyang.tms.manager.forecast.handler.CalculateWeightHandler;
@Component
public class CalWeightProcessPipelineFactory  extends AbstranctTransPipelineFactory<CalWeightRequest>{
    @Autowired
	private CalculateWeightHandler calculateWeightHander;
	@Override
	public TransHandlerContext createContext() {
		return new WeightContext();
	}

	@Override
	public void doBuild(TransPipeline pipeline) {
		pipeline.addLast(calculateWeightHander);
		
	}

	@Override
	public TransPipeline createPipeline(TransHandlerContext context) {
		 return new DefaultTransPipeline(context,super.getDataSourceTransactionManager(),super.getTransactionDefinition()); 
	}

	@Override
	public TransConvert createConvert() {
		return new CalWeightConvert();
	}

}
